package shop;

import java.util.ArrayList;
//201621123079  刘思远
public class Car extends Mart implements CartDao{
	private ArrayList<Goods> gList = new ArrayList<Goods>();
	private ArrayList numList = new ArrayList();
	private double allPrice = 0;
	
	public void addGoodsInCar(int i,int num) {
		gList.add(getOne(i));
		numList.add(num);
		allPrice += (num*gList.get(gList.size()-1).getPrice());
	}
	
	public void removeGoods(int i) {
		allPrice -= (( gList.get(i).getPrice())*((double)numList.get(i)));
		gList.remove(i);
		numList.remove(i);
	}
	
	public void ShowCar() {
		System.out.println("购物车:");
		for (int i = 0; i < gList.size(); i++) {
			System.out.println(gList.get(i).toString() + " 数量: " + numList.get(i));
		}
		System.out.println("总价: " + allPrice);
	}
	
	public void Pay() {
		gList.clear();
		numList.clear();
		allPrice = 0 ;
	}
}
